package vns.server.domain;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import vns.shared.RuleParamDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class RuleParam {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	@Persistent
	private String ruleID;
	@Persistent
	private String reportID; // dung cho report

	@Persistent
	private String varName; // ten bien
	@Persistent
	private String propertyPath;
	@Persistent
	private String type; // pramtype

	@Persistent
	private String name; // report: ten cot
	@Persistent
	private int weight; // report: thu tu cot

	public RuleParam(RuleParamDTO paramDTO) {
		this.ruleID = paramDTO.getRuleID();
		this.reportID = paramDTO.getReportID();
		this.type = paramDTO.getType();
		this.varName = paramDTO.getVarName();
		this.propertyPath = paramDTO.getPropertyPath();
		this.name = paramDTO.getName();
		this.weight = paramDTO.getWeight();
	}

	public void updatefromDTO(RuleParamDTO paramDTO) {
		this.ruleID = paramDTO.getRuleID();
		this.reportID = paramDTO.getReportID();
		this.type = paramDTO.getType();
		this.varName = paramDTO.getVarName();
		this.propertyPath = paramDTO.getPropertyPath();
		this.name = paramDTO.getName();
		this.weight = paramDTO.getWeight();
	}

	public RuleParamDTO toDTO() {
		RuleParamDTO actionparamDTO = new RuleParamDTO(
				this.ruleID, this.reportID, this.type,
				this.varName, this.propertyPath, this.name, this.weight);
		return actionparamDTO;
	}

	public Key getId() {
		return id;
	}

	public void setRuleID(String ruleID) {
		this.ruleID = ruleID;
	}

	public String getRuleID() {
		return ruleID;
	}

	public void setReportID(String reportID) {
		this.reportID = reportID;
	}

	public String getReportID() {
		return reportID;
	}

	public void setVarName(String varName) {
		this.varName = varName;
	}

	public String getVarName() {
		return varName;
	}

	public void setPropertyPath(String propertyPath) {
		this.propertyPath = propertyPath;
	}

	public String getPropertyPath() {
		return propertyPath;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public int getWeight() {
		return weight;
	}
}
